home *** CD-ROM | disk | FTP | other *** search
- rem $linesize:132
- rem $title:'Application Engineer Standard Routines'
- rem $subtitle:'Allocate and return next available record number'
- ' Include the COMMON values
- rem $include:'AESHARED.BAS'
-
- sub Get.Avail.Record (fl%,rlen%,rec%) static
-
- r%=rlen%-8% ' Rest of the record
-
- field #fl%,1 as stat$,2 as n.av$,2 as l.av$,1 as mj$,1 as mn$,1 as bug.fix$
- field #fl%,8 as dummy$,r% as filler$
-
- ' stat$ = Status (1 = Open / 2 = Closed)
- ' n.av$ = Next available record
- ' l.av$ = Last available record
- ' mj$ = Application Engineer Major release version
- ' mn$ = Application Engineer Minor release version
- ' bug.fix$ = Bug fix code within Minor release
-
- get #fl%,1%
-
- if mj$<>chr$(0%) or _
- mn$<>chr$(0%) or _
- bug.fix$<>"B" _
- then
- call ae.error("GAR Version mismatch error. Action 01")
- end if
-
- nav%=cvi(n.av$)
- lav%=cvi(l.av$)
-
- field #fl%,2 as pt$,r%+6% as filler$
- get #fl%,nav%
-
- npt%=cvi(pt$)
-
- if npt%=0% then
- call ae.error("GAR File corruption error. Action 02")
- end if
-
-
- if npt%=-1% then
- if nav%<>lav% then
- call ae.error("GAR File corruption error. Action 03")
- end if
-
- if lav%=32767% then ' Maximum file size is 32767
- call ae.error("GAR File full error. Action 04")
- end if
-
- lav%=lav%+1% ' Increment the last avail to filelen + 1
- rec%=nav% ' Hold the available record number
- lset pt$=mki$(0%) ' Set the status to USED
- put #fl%,nav% ' Put the record back
- nav%=lav% ' Set the next avail to last avail
- lset pt$=mki$(-1%) ' Set status to END OF CHAIN
- put #fl%,nav% ' Put the new next avail
- get #fl%,1% ' Get the header information
- lset n.av$=mki$(nav%) ' Set the new next avail
- lset l.av$=mki$(lav%) ' Set the new last avail
- put #fl%,1% ' Put the header information back
- end if
-
-
- if npt%<>-1% then ' There are more records on file
- rec%=nav% ' Hold the avaialable record number
- lset pt$=mki$(0%) ' Set the status to used
- put #fl%,nav% ' Put the record back
- nav%=npt% ' Next available record chain
- get #fl%,1% ' Get the header information
- lset n.av$=mki$(nav%) ' Set the new next avail
- put #fl%,1% ' Put the header information back
- end if
-
- end sub